home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / bin / DXUtils / AppWizard / DXAppwiz.awx / TEMPLATE / D3DFONT.H < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-25  |  2.4 KB  |  76 lines

  1. //-----------------------------------------------------------------------------
  2. // File: D3DFont.h
  3. //
  4. // Desc: Texture-based font class
  5. //-----------------------------------------------------------------------------
  6. #ifndef D3DFONT_H
  7. #define D3DFONT_H
  8. #include <tchar.h>
  9. #include <D3D8.h>
  10.  
  11.  
  12. // Font creation flags
  13. #define D3DFONT_BOLD        0x0001
  14. #define D3DFONT_ITALIC      0x0002
  15. #define D3DFONT_ZENABLE     0x0004
  16.  
  17. // Font rendering flags
  18. #define D3DFONT_CENTERED    0x0001
  19. #define D3DFONT_TWOSIDED    0x0002
  20. #define D3DFONT_FILTERED    0x0004
  21.  
  22.  
  23.  
  24.  
  25. //-----------------------------------------------------------------------------
  26. // Name: class CD3DFont
  27. // Desc: Texture-based font class for doing text in a 3D scene.
  28. //-----------------------------------------------------------------------------
  29. class CD3DFont
  30. {
  31.     TCHAR   m_strFontName[80];            // Font properties
  32.     DWORD   m_dwFontHeight;
  33.     DWORD   m_dwFontFlags;
  34.  
  35.     LPDIRECT3DDEVICE8       m_pd3dDevice; // A D3DDevice used for rendering
  36.     LPDIRECT3DTEXTURE8      m_pTexture;   // The d3d texture for this font
  37.     LPDIRECT3DVERTEXBUFFER8 m_pVB;        // VertexBuffer for rendering text
  38.     DWORD   m_dwTexWidth;                 // Texture dimensions
  39.     DWORD   m_dwTexHeight;
  40.     FLOAT   m_fTextScale;
  41.     FLOAT   m_fTexCoords[128-32][4];
  42.  
  43.     // Stateblocks for setting and restoring render states
  44.     DWORD   m_dwSavedStateBlock;
  45.     DWORD   m_dwDrawTextStateBlock;
  46.  
  47. public:
  48.     // 2D and 3D text drawing functions
  49.     HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor, 
  50.                       TCHAR* strText, DWORD dwFlags=0L );
  51.     HRESULT DrawTextScaled( FLOAT x, FLOAT y, FLOAT z, 
  52.                             FLOAT fXScale, FLOAT fYScale, DWORD dwColor, 
  53.                             TCHAR* strText, DWORD dwFlags=0L );
  54.     HRESULT Render3DText( TCHAR* strText, DWORD dwFlags=0L );
  55.     
  56.     // Function to get extent of text
  57.     HRESULT GetTextExtent( TCHAR* strText, SIZE* pSize );
  58.  
  59.     // Initializing and destroying device-dependent objects
  60.     HRESULT InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice );
  61.     HRESULT RestoreDeviceObjects();
  62.     HRESULT InvalidateDeviceObjects();
  63.     HRESULT DeleteDeviceObjects();
  64.  
  65.     // Constructor / destructor
  66.     CD3DFont( TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags=0L );
  67.     ~CD3DFont();
  68. };
  69.  
  70.  
  71.  
  72.  
  73. #endif
  74.  
  75.  
  76.